﻿-- =============================================
-- Author:			Nicolas Lareu
-- Create date:		<MMMM> <DD>, <YYYY>
-- Description:		<Description>
-- =============================================
CREATE FUNCTION CAT.GetProductPrice
(
	@id INT = NULL
)
RETURNS FLOAT
AS
BEGIN
	DECLARE @price FLOAT

	IF (@id IS NOT NULL)
		SET @price = (SELECT TOP 1 Price FROM CAT.Products WHERE Id = @id)
	ELSE
		SET @price = NULL

	RETURN @price
END

GO
GRANT EXECUTE
    ON OBJECT::CAT.GetProductPrice TO [SystemPublic]
    AS [dbo];
